﻿try {
    var isSupport = 'localStorage' in window && window['localStorage'] !== null;
    if (isSupport) {
        localStorage.setItem('private__test', 'testStr');
        localStorage.removeItem('private__test');
    }
} catch (e) {
    alert('您处于无痕浏览，无法保存用户信息，请退出无痕模式重新浏览网站')
}

const Storage = {
    get:(value) => {
        try {
            let val = localStorage.getItem(value)
            try { return JSON.parse(val) }
            catch(e) { return val || undefined }
        }catch (e) {
            return
        }
    },
    set:(key,value) => {
        try {
            if (value === undefined) { return }
            localStorage.setItem(key,JSON.stringify(value))
        }catch (e) {
            return
        }
    },
    remove:(key) => {
        try {
            localStorage.removeItem(key)
        }catch (e) {
            return
        }
    }
}

export default Storage
